# name : rpact getSampleSizeSurvival function with eventratio
# key : rpact.getSampleSizeSurvival.func.eventratio
# contributor: Shuguang Sun
# --
${1:sz_ttnt} <- function(x, eventratio = 0.75) {
  sz1 <- getSampleSizeSurvival(
    alpha = 0.025, sided = 1,
    beta = x$beta,
    lambda1 = log(2) / x$active,
    lambda2 = log(2) / x$control,
    ## hazardRatio = x$hr,
    followUpTime = 0,
    ## accrualTime = c(0, 1000),
    accrualTime = 0,
    accrualIntensity = x$accrualIntensity,
    dropoutRate1 = 0.01,
    dropoutRate2 = 0.05,
    dropoutTime = 12
  )

  sz2 <- getSampleSizeSurvival(
    alpha = 0.025, sided = 1,
    beta = x$beta,
    lambda1 = log(2) / x$active,
    lambda2 = log(2) / x$control,
    ## hazardRatio = x$hr,
    accrualTime = 0,
    accrualIntensity = x$accrualIntensity,
    maxNumberOfSubjects = 2 * ceiling(sz1$eventsFixed / eventratio / 2),
    dropoutRate1 = 0.01,
    dropoutRate2 = 0.05,
    dropoutTime = 12
  )

  ret <- c(nevent = ceiling(sz1$eventsFixed),
           N = ceiling(sz2$numberOfSubjects1) + ceiling(sz2$numberOfSubjects2),
           accrualTime = max(sz2$accrualTime),
           studyDuration = sz2$studyDuration,
           followUpTime = sz2$followUpTime)
}
